/**********************************************************************/
#include <iostream>
/**********************************************************************/
#include "server.h"
#include "controlserver.h"

/**********************************************************************/
using namespace std;

/**********************************************************************/
void ControlServer::start (quint16 port)
{
  if (!listen (QHostAddress::Any, port))
  {
    emit error(QString(SOCK "error to listen on port %1").arg(port));
    return;
  }

  emit logMessage(QString(SOCK "control server started on port: %1")
                  .arg(port));
}

/**********************************************************************/
void ControlServer::stop()
{
  emit logMessage(QString(SOCK "closing port %1 and shutting down...")
                  .arg(serverPort()));
  close();
}

/**********************************************************************/
void ControlServer::quit()
{
  close();
  deleteLater();
}

void ControlServer::printLogMessage(QString msg)
{
  cout << msg.toStdString() << endl;
}
